import Vue from "vue";
import Vuex from "vuex";
import createPersistedState from "vuex-persistedstate";
Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    userInfo: "",
    SERVERBASE_URL: "",
    RECORD_URL: "",
    imgServerUrl: "", //图片服务器地址
    ownModel:"A30",
    aboutInfo: {},
    MANAGA_URL:"",
    idleTime:6000000,
    blindReview:false
  },
  mutations: {
    //设置登录用户
    SET_USERINFO(state, payload) {
      state.userInfo = payload;
      window.localStorage.setItem("user", JSON.stringify(payload));
    },
    //设置服务器地址
    SET_SERVERBASE_URL(state, payload) {
      state.SERVERBASE_URL = payload;
    },
    //设置检查记录服务地址
    SET_RECORD_URL(state, payload) {
      state.RECORD_URL = payload;
    },
    //初始化数据
    INITSTATE(state) {
      state.userInfo = "";
      state.SERVERBASE_URL = "";
      state.RECORD_URL = "";
    },
    //图片服务器地址
    SET_IMGSERVER(state, payload) {
      state.imgServerUrl = payload;
    },
    //设置自主型号
    SET_OWNMODEL(state, payload){
      state.ownModel = payload
    },
    SET_ABOUTINFO(state, payload) {
      state.aboutInfo = payload;
    },
    SET_MANAGA(state, payload){
      state.MANAGA_URL = payload
    },
    SET_IDLETIME(state, payload){
      state.idleTime = payload
    },
    SET_BLINDREVIEW(state, payload){
      state.blindReview = payload
    }
  },
  plugins: [
    createPersistedState({
      storage: window.sessionStorage,
    }),
  ],
});
